@extends('admin/layout')
@section('title','商品管理')
@section('introduce')
<script src="{{asset('admin/local/imageselect/imageselect.js')}}"></script>
<link rel="stylesheet" href="{{asset('admin/local/imageselect/imageselect.css')}}"/>
@stop
@section('content')
<!-- Content Header (Page header) -->
<section class="content-header">
  <h1>
    商品列表
    <small>添加商品属性</small>
  </h1>
  <ol class="breadcrumb">
  	<li><a href="{{asset('admin/index')}}"><i class="fa fa-th"></i> 管理首页</a></li>
    <li><i class="fa fa-shopping-cart"></i> 商品管理</li>
    <li><a href="{{asset('admin/product')}}"><i class="fa fa-list-ul"></i> 商品列表</a></li>
    <li class="active">添加商品属性</li>
  </ol>
</section>

<!-- Main content -->
<section class="content">
	<div class="row">
		<div class="col-md-12">
	  	  <!-- box start -->
          <div class="box box-info">
	        <div class="box-header with-border">
	          <h3 class="box-title"><i class="fa fa-cart-plus"> 添加商品属性</i></h3>
	        </div>
          @if(session('error'))
            {{session('error')}}
          @endif
          @if(count($errors)>0)
          <div class="alert alert-danger">
            <ul>
              @foreach($errors->all() as $error)
                <li>{{$error}}</li>
              @endforeach
            </ul>
          </div>
          @endif
          
            <!-- form start -->
            <form class="form-horizontal" id="main_form" action="{{asset('admin/productattr')}}" method="post" enctype="multipart/form-data">
              {{csrf_field()}}
              <div class="box-body">
                <div id="attr" style="">
                  <input type="hidden" value="{{$pro_id}}" name="pro_id"/>
                  <div class="form-group">
                    <label for="selectcolor" class="col-sm-1 col-md-2 control-label">色系：</label>
                    <div class="col-sm-3 col-md-2">
                      <select id="selectcolor" class="form-control" name="col_id">
                        @foreach($colors as $v)
                        <option value="{{$v->color_id}}" style="background:{{$v->color_hex_code}};">{{$v->color_name_zh}}</option>
                      @endforeach
                      </select>

                    </div>
                    <div id="colordiv" class="col-sm-1 col-md-1" style="background:pink;width:30px;height:30px;border:1px solid black"></div>
                    <script>
                      $('#selectcolor').on('change',function(){
                        //console.log($(this).val());
                        var val=parseInt($(this).val());
                        //console.log(val);
                        var choose=$('option:checked').css('background-color');
                        //console.log(choose);
                        $('#colordiv').css('background-color',choose);
                      });
                    </script>
                  </div>


                  <div class="form-group {{--has-error--}}">
                    <label for="" class="col-sm-2 col-md-2 control-label" name="">尺寸/库存：</label>
                  </div>
                  {!!$sizes_str!!}
                  <script>
                    
                    $('[type=checkbox]').on('click',function(){
                      //console.log($(this).val());
                      var this_stocknum=$(this).parent().next().children().first();
                      //console.log(this_stocknum.attr('disabled'));
                      if(this_stocknum.attr('disabled')=='disabled'){
                        this_stocknum.attr('disabled',false);
                      }else{
                        this_stocknum.attr('disabled',true);
                      }

                    });
                  </script>
                  <div class="form-group">
                    <label for="" class="col-sm-2 col-md-2 control-label" name="carouse_pic1">轮播图片：</label>
                    <div class="col-sm-10 col-md-10">
                      <input type="file" class="" id="" name="carouse_pic1">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="" class="col-sm-2 col-md-2 control-label"></label>
                    <div class="col-sm-10 col-md-10">
                      <input type="file" class="" id="" name="carouse_pic2">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="" class="col-sm-2 col-md-2 control-label"></label>
                    <div class="col-sm-10 col-md-10">
                      <input type="file" class="" id="" name="carouse_pic3">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="" class="col-sm-2 col-md-2 control-label"></label>
                    <div class="col-sm-10 col-md-10">
                      <input type="file" class="" id="" name="carouse_pic4">
                    </div>

                  </div>
                </div>
                 
                 
              
              </div>
              <div class="row">
                <button id="addattr" class="btn bg-purple col-md-offset-1">继续添加</button>

              </div>
                <script>
                    $('#addattr').on('click',function(){
                      $('#main_form').attr('action',"{{asset('admin/productattrnext')}}");
                      //console.log($('#main_form').attr('action'));


                    });
                    //$('#addattr').on('click',function(){
                    //   var otherattr=$('#attr').clone(true,true);
                      
                    //   otherattr.find('[type=checkbox]').attr('checked',false);
                    //   otherattr.find('[type=text]').val('');
                    //   $('.box-body').append(otherattr);
                    // });
                </script>
              <div class="box-footer">
                <input type="reset" class="btn btn-default col-sm-2 col-sm-offset-2 col-md-2 col-md-offset-2" value="清空"/>
                <button class="btn btn-info col-xs-offset-1 col-sm-2 col-sm-offset-1 col-md-2 col-md-offset-1">提交</button>
              </div>
            </form>
            <!-- /.form -->
          </div>
          <!-- /.box -->
	    </div>
    </div>
</section>
<!-- /.content -->
@stop